import {
  Module,
  VuexModule,
  Mutation,
  getModule,
} from "vuex-module-decorators";
import store from "@/store";
import Icanvas from "@/interface/canvas/Icanvas";
import ITextCanvas from "@/interface/canvas/ITextCanvas";
import IRectCanvas from "@/interface/canvas/IRectCanvas";

@Module({ dynamic: true, store, namespaced: true, name: "Canvas" })
class canvas extends VuexModule {
  canvasList: Icanvas = {
    canvas: [],
  };

  get getcanvasList(): Array<ITextCanvas | IRectCanvas> {
    return this.canvasList.canvas;
  }

  @Mutation
  changecanvasList(list: ITextCanvas | IRectCanvas): void {
    this.canvasList.canvas.push(list);
  }

  @Mutation
  clearCanvasList(): void {
    this.canvasList.canvas.length = 0;
  }
}

const canvasListModule = getModule(canvas);

export default canvasListModule;
